import axios from 'axios';

//获取当前文件的上传情况
export function getUploadInfo(data) {
	return axios({
		url: '/sys-storage/secondPass',
		method: 'post',
		params: { ...data }
	});
}

//获取当前上传文件唯一标识
export function getUploadId(data) {
	return axios({
		url: '/sys-storage/uploadId',
		method: 'get',
		params: { ...data }
	});
}

//获取当前文件已上传的分片列表
export function getFileBlockList(data) {
	return axios({
		url: '/sys-storage/parts',
		method: 'get',
		params: { ...data }
	});
}

//分片上传
// export function uploadFileBlock(data) {
//     return axios({
//         url: "/sys-storage/bigFile",
//         method: "post",
//         data
//     });
// }

//取消上传，清空相关信息
export function deleteFileInfo(data) {
	return axios({
		url: '/sys-storage/abort/burst',
		method: 'delete',
		params: { ...data }
	});
}

//分片上传完成，合并文件
export function mergeFile(data) {
	return axios({
		url: '/sys-storage/bigFile/together',
		method: 'post',
		data,
		transformRequest: [
			function (data) {
				return JSON.stringify(data);
			}
		],
		headers: {
			'Content-Type': 'application/json;charset=UTF-8'
		}
	});
}

//查询文件组信息
export function getGroupFileInfo(data) {
	return axios({
		url: '/sys-storage/file',
		method: 'post',
		data
	});
}

export function deleteFile(data) {
	return axios({
		url: '/sys-storage/file',
		method: 'delete',
		data,
		transformRequest: [
			function (data) {
				return JSON.stringify(data);
			}
		],
		headers: {
			'Content-Type': 'application/json;charset=UTF-8'
		}
	});
}
